1 module features.ldc; 2 import commons; 3 import feature; 4 enum LdcVersion = "1.41.0"; 5 6 7 /** 8 * Must check if ~/.ldc2.conf (%APPDATA%\.ldc\ldc2.conf) exists and then ignore it. 9 * This is a fix since Hipreme Engine should contain the entire build command and make it 10 * predictable. 11 * Here, it uses the 2nd ldc2.conf, so, one is still able to tweak although not recommended 12 * https://wiki.dlang.org/Using_LDC - Next to ldc2 executable. 13 */ 14 private void overrideLdcConf(ref Terminal t, string outputPath) 15 { 16 static import std.file; 17 string ldc2Conf = buildNormalizedPath(outputPath, "etc", "ldc2.conf"); 18 t.writelnHighlighted("Overriding ldc2.conf to use one next to ldc executable."); 19 std.file.copy(ldc2Conf, buildNormalizedPath(outputPath, "bin", "ldc2.conf")); 20 } 21 22 23 bool installLdc(ref Terminal t, ref RealTimeConsoleInput input, TargetVersion ver, Download[] downloads) 24 { 25 import commons:removeExtension; 26 string ldcPath = buildNormalizedPath(std.file.getcwd, "D", downloads[0].url.getDownloadFileName(ver).removeExtension); 27 auto binPath = buildNormalizedPath(ldcPath, "bin"); 28 foreach(executable; ["ldc2", "ldmd2", "rdmd", "dub"]) 29 makeFileExecutable(buildNormalizedPath(binPath, executable)); 30 overrideLdcConf(t, ldcPath); 31 32 string rdmd = buildNormalizedPath(binPath, "rdmd"); 33 version(Windows) rdmd = rdmd.setExtension("exe"); 34 configs["ldcVersion"] = ver.toString; 35 configs["ldcPath"] = ldcPath; 36 configs["dubPath"] = binPath; 37 updateConfigFile(); 38 39 40 return true; 41 } 42 43 44 45 Feature LDCFeature; 46 void initialize() 47 { 48 LDCFeature = Feature( 49 "LDC 2", 50 "LLVM Backend D Compiler. Used for development on various platforms", 51 ExistenceChecker(["ldcPath"]), 52 Installation([ 53 Download( 54 DownloadURL( 55 windows: "https://github.com/ldc-developers/ldc/releases/download/v$VERSION/ldc2-$VERSION-windows-x64.7z", 56 linux: "https://github.com/ldc-developers/ldc/releases/download/v$VERSION/ldc2-$VERSION-linux-x86_64.tar.xz", 57 osx: "https://github.com/ldc-developers/ldc/releases/download/v$VERSION/ldc2-$VERSION-osx-universal.tar.xz" 58 ), 59 outputPath: "$TEMP$NAME", 60 ) 61 ], toDelegate(&installLdc), ["$CWD/D/"]), 62 (ref Terminal t, string ldcPath) 63 { 64 addToPath(ldcPath.buildNormalizedPath("bin")); 65 }, 66 VersionRange.parse(LdcVersion), 67 ); 68 69 } 70 71 void start() 72 { 73 import features._7zip; 74 LDCFeature.dependencies = [&_7zFeature]; 75 }